<template>
	<!--        头部栏-->

<!--	富文本编辑器-->
  <div class="global-quill-editor">
    <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
      <el-form-item label="文章标题">
			<el-input v-model="formLabelAlign.region" style="width: 300px; margin-right: 466px; margin-top: 10px;"></el-input>
      </el-form-item>
      <el-form-item label="内容类型">
			<el-input v-model="formLabelAlign.type" style="width: 300px; margin-right: 466px;"></el-input>
      </el-form-item>
	  <el-form-item label="">
		  <div style="margin: auto;">
		   <quill-editor
			 ref="myGQuillEditor"
			 v-model="content"
			 :options="editorOption"
			 class="editor"
			 @blur="onEditorBlur"
			 @focus="onEditorFocus"
			 @change="onEditorChange"
		   >
		   </quill-editor>
		   </div>
	  </el-form-item>
	   <el-form-item >
		   <div id="but1">
			<el-button type="danger" plain>保存草稿</el-button>
		    <el-button type="success" plain>发布文章</el-button>
			</div>
	   </el-form-item>
    </el-form>
  </div>
</template>

<script>
// 工具栏配置项
const toolbarOptions = [
  // 加粗 斜体 下划线 删除线 -----['bold', 'italic', 'underline', 'strike']
  ['bold', 'italic', 'underline', 'strike'],
  // 引用  代码块-----['blockquote', 'code-block']
  ['blockquote', 'code-block'],
  // 1、2 级标题-----[{ header: 1 }, { header: 2 }]
  [{ header: 1 }, { header: 2 }],
  // 有序、无序列表-----[{ list: 'ordered' }, { list: 'bullet' }]
  [{ list: 'ordered' }, { list: 'bullet' }],
  // 上标/下标-----[{ script: 'sub' }, { script: 'super' }]
  [{ script: 'sub' }, { script: 'super' }],
  // 缩进-----[{ indent: '-1' }, { indent: '+1' }]
  [{ indent: '-1' }, { indent: '+1' }],
  // 文本方向-----[{'direction': 'rtl'}]
  [{ direction: 'rtl' }],
  // 字体大小-----[{ size: ['small', false, 'large', 'huge'] }]
  [{ size: ['small', false, 'large', 'huge'] }],
  // 标题-----[{ header: [1, 2, 3, 4, 5, 6, false] }]
  [{ header: [1, 2, 3, 4, 5, 6, false] }],
  // 字体颜色、字体背景颜色-----[{ color: [] }, { background: [] }]
  [{ color: [] }, { background: [] }],
  // 字体种类-----[{ font: [] }]
  [{ font: [] }],
  // 对齐方式-----[{ align: [] }]
  [{ align: [] }],
  // 清除文本格式-----['clean']
  ['clean'],
  // 链接、图片、视频-----['link', 'image', 'video']
  ['image', 'video']
]

export default {
  name: 'GlobalQuillEditor',
  data () {
    return {
	    labelPosition: 'right',
		formLabelAlign: {
		  content: '',
		  region: '',
		  type: ''
		},
	    editorOption: {
			modules: {
				toolbar: toolbarOptions
			},
			theme: 'snow',
			placeholder: '请输入正文'
	    }
		}
	  },
  methods: {
    // 失去焦点事件
    onEditorBlur (e) {
      console.log('onEditorBlur: ', e)
    },
    // 获得焦点事件
    onEditorFocus (e) {
      console.log('onEditorFocus: ', e)
    },
    // 内容改变事件
    onEditorChange (e) {
      console.log('onEditorChange: ', e)
    }
  }
}
</script>

<style>
.editor {
  height: 300px;
}
/* 背景div */
.global-quill-editor{
	border: 3px solid #21231E;
	width: 700px;
	height: 800px;
	margin: auto;
}
#but1{
	 position: absolute;
	 top: -416px;
	 right: 50px;
}
</style>